package pe.integracion.config;

import java.io.InputStream;
import java.util.Properties;

import pe.integracion.Retorno;

public abstract class CMISFacadeAbstract {

	private SessionParameters sp;
	private CMISManager cmisManager;
	private static Properties resourceBundle = new Properties();

	protected CMISFacadeAbstract() {
		super();
		try {
			InputStream inputStream = CMISFacadeAbstract.class
					.getClassLoader()
					.getResourceAsStream(
							"pe/integracion/config/CMISConfiguration.properties");
			resourceBundle.load(inputStream);
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.sp = new SessionParameters(
				resourceBundle.getProperty("USER_NAME"),
				resourceBundle.getProperty("PASSWORD"),
				resourceBundle.getProperty("CMIS_SERVICE_URL"),
				resourceBundle.getProperty("SITE_ROOT_FOLDER_PATH"),resourceBundle.getProperty("CONNECT_TIME_OUT"),resourceBundle.getProperty("READ_TIME_OUT"));
		cmisManager = new CMISManager(sp);
	}

	protected Retorno existDirectory(String folderName) {
		return this.cmisManager.existDirectory(folderName);
	}

	protected Retorno createDirectory(String folderName) {
		return this.cmisManager.createDirectory(folderName);
	}

	protected Retorno existDocument(String uuid) {
		return this.cmisManager.existDocument(uuid);
	}

	protected Retorno createDocument(byte[] file, String directory,
			String fileName, String mimetype) {
		return this.cmisManager.createDocument(file, directory, fileName,
				mimetype);
	}

	protected Retorno getDocument(String uuid) {
		return this.cmisManager.getDocument(uuid);
	}

	public Retorno deleteDocument(String uuid) {
		return this.cmisManager.deleteDocument(uuid);
	}

	public Retorno deleteDirectory(String folderName) {
		return this.cmisManager.deleteDirectory(folderName);
	}
	
	public Retorno queryForContent(String patron) {
		return this.cmisManager.queryForContent(patron);
	}
	
	
}
